﻿Option Explicit On
Option Strict On

' Copyright © Microsoft Corporation.  All Rights Reserved.
' This code released under the terms of the 
' Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)


Imports System
Imports System.Security.Permissions
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Security
Imports Microsoft.SharePoint.Utilities
Imports Microsoft.SharePoint.Workflow
Imports System.Diagnostics

Public Class DonationDeleting 
    Inherits SPItemEventReceiver

	''' <summary>
    ''' Sample EventHandler that prevents the user from deleting an imtem in the donations list which has an amount greater than 0
	''' </summary>
    Public Overrides Sub ItemDeleting(ByVal properties As SPItemEventProperties)
        Try
            Dim amount As Double = CDbl(properties.ListItem("Amount"))
            If (amount > 0) Then
                properties.ErrorMessage = "You cannot delete donations with an amount greater than 0. We want to keep the money!"
                properties.Cancel = True
            End If
        Catch ex As Exception
            EventLog.WriteEntry("SP Event Handler", ex.Message)
        End Try
    End Sub


End Class
